package com.codejam.gof.decrator;

import com.codejam.gof.decrator.concrete.Drink;
import lombok.Data;

/**
 * 饮料
 */
@Data
public class Decorator extends Drink {

    private Drink obj;

    public Decorator() {
    }

    public Decorator(Drink obj) {
        this.obj = obj;
    }

    @Override
    public float cost() {

        //先拿到自己的价格
        float price = super.getPrice();


        //再拿到主饮料的价格
        float price1 = obj.getPrice();


        return price + price1;
    }


    @Override
    public String getDesc() {

        //装饰着信息
        String desc = super.getDesc();

        //被装饰者信息
        String desc1 = obj.getDesc();

        return desc + "&&" + desc1;
    }
}
